﻿using System;
using System.Collections.Generic;


namespace MyHealthByDesign.Domain.Processing
{
    /// <summary>
    /// Description:
    /// InchCentimeterConversion class provides processing logic for InchCentimeterConversion processing type.
    /// 
    /// Author: Mark Servais
    /// Date Created: 11/22/2011
    /// 
    /// Other code files referenced:
    /// IProcessing.cs
    /// 
    /// Regression Test Information:
    /// InchCentimeterConversion_Test.cs in project MyHealthByDesign_Test
    /// 
    /// Revision History:
    /// None.
    /// 
    /// Known Faults:
    /// None.
    /// </summary>
    public class InchCentimeterConversion : IProcessing
    {
        #region IProcessing Members

        /// <summary>
        /// RunProcessingForField - Executes the processing logic
        /// web page
        /// 
        /// PreConditions:
        /// None
        /// 
        /// PostConditions:
        /// boolean value is returned based on success of logic
        /// </summary>
        /// <param name="question"></param>
        /// <returns></returns>
        public bool RunProcessingForField(Question question, QuestionProcessing process)
        {
            bool bValid = false;

            try
            {
                List<string> listValues = new List<string>(process.QuestionProcessingValues.Split('|'));

                HtmlAttribute attribute = new HtmlAttribute();
                attribute.ForFieldName = process.FieldName;
                attribute.Keyword = listValues[0];
                attribute.Statement = listValues[1];

                question.Attributes.Add(attribute);

                bValid = true;
            }
            catch (Exception)
            {
                bValid = false;
            }
            

            return bValid;
        }

        #endregion
    }
}